-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Urlsession retry strategy #7708
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 13 files at r1, all commit messages.
Reviewable status: 11 of 13 files reviewed, 2 unresolved discussions
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
#[no_mangle] pub unsafe extern "C" fn mullvad_api_retry_strategy_never() -> SwiftRetryStrategy {
We should have # Safety
warnings for all these functions marked unsafe
mullvad_api_get_addresses
has a good example of what these should cover
ios/MullvadREST/RetryStrategy/RetryStrategy.swift
line 25 at r1 (raw file):
} /// The return value of this function *must* be passed to a Rust FFI funciton that will consume it, otherwise it will leak.
nit
funciton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, we'll have to make sure that the tests in RetryStrategyTests
use the rust iterators if possible
Reviewable status: 11 of 13 files reviewed, 2 unresolved discussions (waiting on @SteffenErn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 13 of 13 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
Previously, buggmagnet wrote…
We should have
# Safety
warnings for all these functions marked unsafe
mullvad_api_get_addresses
has a good example of what these should cover
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
Previously, rablador (Jon Petersson) wrote…
+1
Under what circumstances would it be unsafe to call this function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 13 files at r1, 1 of 2 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 13 files at r1, 1 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
564b020
to
3380650
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
3380650
to
2092c46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r3.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 48 at r4 (raw file):
/// Creates a retry strategy that never retries after failure. /// The result needs to be consumed.
Consumed by what? I think this could be elaborated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @pinkisemils, @rablador, and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
Technically none of these are inherently unsafe, but to quote the rust documentation
All FFI (Foreign Function Interface) functions are
unsafe
to call because the other language can do arbitrary operations that the Rust compiler can't check.
We can just state in the # Safety
lines that the functions are safe to call, as we do all across our existing Rust codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
Previously, buggmagnet wrote…
Technically none of these are inherently unsafe, but to quote the rust documentation
All FFI (Foreign Function Interface) functions are
unsafe
to call because the other language can do arbitrary operations that the Rust compiler can't check.We can just state in the
# Safety
lines that the functions are safe to call, as we do all across our existing Rust codebase.
What is the safety hazard in calling this function? I am asking because I want to understand what are you trying to get at.
As far as I can tell, this call is always safe, it will panic and crash badly only in the case where it fails to allocate memory or there is not enough stack space to call it safely. If we are going to document those failure modes, then we can presume that all function calls are not safe. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @buggmagnet and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
Previously, pinkisemils (Emīls Piņķis) wrote…
What is the safety hazard in calling this function? I am asking because I want to understand what are you trying to get at.
As far as I can tell, this call is always safe, it will panic and crash badly only in the case where it fails to allocate memory or there is not enough stack space to call it safely. If we are going to document those failure modes, then we can presume that all function calls are not safe. Am I missing something?
Maybe the correct thing to do here is to not mark these functions as unsafe instead :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @pinkisemils, @rablador, and @SteffenErn)
mullvad-ios/src/api_client/retry_strategy.rs
line 49 at r1 (raw file):
Previously, pinkisemils (Emīls Piņķis) wrote…
Maybe the correct thing to do here is to not mark these functions as unsafe instead :)
Yes if we can do that and have the compiler be happy about it, that would be my preferred option too
2092c46
to
4c88676
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r5, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @pinkisemils and @SteffenErn)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @SteffenErn)
4c88676
to
68352d1
Compare
Adding the ability to retry api calls to Rust. It uses the same retry strategy as the previous URLSession calls.
This change is